package cn.wowjoy.pda.android_pharmacy.mvvm.vm;

import java.util.ArrayList;

import cn.wowjoy.pda.android_pharmacy.common.core.BaseViewModel;
import cn.wowjoy.pda.android_pharmacy.model.xmlEntity.putInfo.PutSingleBeen;

/**
 * Created by Administrator on 2017/8/29.
 */

public class InHospitalPutHandViewModel extends BaseViewModel {
    //每次被移除的一个Been
    public PutSingleBeen remove;
    public ArrayList<PutSingleBeen> FirstTotal;
    //第一次的全部数据 实体类   每取一次就把第一个移出去，放入到另外一个集合
    public ArrayList<PutSingleBeen> mMoveBaens;
//    public  ArrayList<PutSingleBeen> mTestBeen = new ArrayList<>();

    public  boolean updateResult =false;
    public void show(ArrayList<PutSingleBeen> mDatas) {
        if (null == FirstTotal)
            FirstTotal = new ArrayList<>();
        FirstTotal.clear();
        FirstTotal.addAll(mDatas);


        if (null == mMoveBaens)
            mMoveBaens = new ArrayList<>();
        mMoveBaens.clear();
        mMoveBaens.addAll(mDatas);
    }
    public  boolean   checkSecond(PutSingleBeen inHospitalPatientBeen) {
        if (null != FirstTotal && FirstTotal.size() > 0) {
            for (PutSingleBeen i : FirstTotal) {
                if (null != i.getYPSPBM() && i.getYPSPBM().equals(inHospitalPatientBeen.getYPSPBM())
                        || null != i.getYPJGBM() && i.getYPJGBM().equals(inHospitalPatientBeen.getYPJGBM())
                        || null != i.getKFWZMC() && i.getKFWZMC().equals(inHospitalPatientBeen.getKFWZMC())
                        ) {
                    //匹配成功
                    if (i.isPut()) {
                        return false;
                    }
                    i.setPut(true);
                    return true;
                }
            }
        }
        return false;
    }
    public boolean checkOver(){
        for(PutSingleBeen i : FirstTotal){
            if(!i.isPut()){
                return false;
            }
        }
        return true;
    }
}
